
#include "User.h"
#include "PathTraverser.h"
#include "Pathfinder.h"

extern Pathfinder goGetEm;
extern Grid<bool> occupancy;
extern Triple getRandPos();
extern Triple playerPos;

		
User::User() {
	
}

User::User(Objects3D l) : user(l) {}

User::~User() {}

void User::changeUserObjects(Objects3D l) {

	this->user = l;
}

void User::addUserObject(int uOb, Agent* p) {

	this->user.addItem(uOb, p);
}

void User::removeUserObject(int uOb) {

	this->user.remove(uOb);	

}
		
int User::numUser() {

	return this->user.size();
}

void 
User::scanAndUpdate() 
{
	// Control for the player goes here!!!
	list<Agent *>::reference currUser = user.objects.front();
	Agent::State currState = currUser->getState();

	switch( currState )
	{
	case Agent::Walking:
		currUser->update();
		break;
	case Agent::Idle:
		Triple pos = getRandPos();

		int id = 2900;

		dbMakeObjectPlane		( id , 100, 100 );
		dbXRotateObject			( id , -90 );
		dbPositionObject		( id , pos.x , 0.5 , pos.z );
		dbColorObject			( id, 0x00FF0000 );
		dbSetObjectCollisionOff ( id );

		currUser->moveTo( pos );
		break;
	}

	playerPos = currUser->getPosition();
}

